import request from '../utils/request'

export const insertAnswer = (questionId, answerDTO) => {
	return request({
		url: `/questions/${questionId}/answers`,
		method: 'POST',
		data: answerDTO,
	})
}

export const listAnswers = (questionId, order) => {
	return request({
		url: `/questions/${questionId}/answers?order=${order}`,
		method: 'GET',
	})
}

export const updateAnswer = (answerId, answer) => {
	return request({
		url: `/answers/${answerId}`,
		method: 'PATCH',
		data: answer,
	})
}

export const listAnswersByUserId = (currentPage, pageSize, userId) => {
	return request({
		url: `/answers?offset=${currentPage}&limit=${pageSize}&userId=${userId}`,
		method: 'GET',
	})
}

export const removeAnswer = (answerId) => {
	return request({
		url: `/answers/${answerId}`,
		method: 'DELETE',
	})
}
